<?php
	require('./init.php');
	$username=$_POST['username'];
	$password=$_POST['password'];
	
	$uid=$redis->get('user:'.$username);
	if($uid){
		$pwd=$redis->hget('user:'.$uid,'password');
		if($pwd == $password){
			$auth=md5(time().rand());
			setcookie('auth',$auth,time()+86400);
			$redis->set('auth:'.$auth,$uid);
			header('location:./list.php');
		}else{
			
			echo '密码不对';
		}
		
	}else{
		echo 'error';
	}
?>

<!doctype html>
<html>
<head>
	<meta charset='utf-8'>
</head>
<body>
	<form action='' method='post'>
		用户名<input type='text' name='username'><br/>
		密码<input type='text' name='password'><br/>
		<input type='submit'>
	</form>
</body>
</html>